// TomatoConfigDialog.h
#ifndef TOMATOCONFIGDIALOG_H
#define TOMATOCONFIGDIALOG_H

#include <QDialog>
#include <QSlider>
#include <QComboBox>
#include <QCheckBox>
#include <QPushButton>
#include <QGroupBox>
#include <QLabel>
#include <QSpinBox>
#include <QListWidget>

class TomatoConfigDialog : public QDialog
{
    Q_OBJECT

public:
    explicit TomatoConfigDialog(QWidget* parent = nullptr);

    // 获取配置
    QString getWorkSound() const;
    QString getRestSound() const;
    QString getBackgroundSound() const;
    QString getBackgroundImage() const;
    bool isDesktopNotificationEnabled() const;
    bool isSoundEnabled() const;
    bool isVibrationEnabled() const;
    int getWorkDuration() const;
    int getRestDuration() const;
    int getVolume() const;
    bool isSkipRestEnabled() const;

private slots:
    void browseWorkSound();
    void browseRestSound();
    void browseBackgroundSound();
    void browseBackgroundImage();
    void playWorkSound();
    void playRestSound();
    void playBackgroundSound();
    void previewBackgroundImage();
    void applySettings();
    void resetToDefault();

private:
    void setupUI();
    void setupConnections();
    void loadCurrentSettings();

    // 声音设置
    QGroupBox* m_soundGroup;
    QComboBox* m_workSoundCombo;
    QComboBox* m_restSoundCombo;
    QComboBox* m_bgSoundCombo;
    QPushButton* m_browseWorkSoundBtn;
    QPushButton* m_browseRestSoundBtn;
    QPushButton* m_browseBgSoundBtn;
    QPushButton* m_playWorkSoundBtn;
    QPushButton* m_playRestSoundBtn;
    QPushButton* m_playBgSoundBtn;
    QSlider* m_volumeSlider;
    QLabel* m_volumeLabel;

    // 外观设置
    QGroupBox* m_appearanceGroup;
    QComboBox* m_bgImageCombo;
    QPushButton* m_browseBgImageBtn;
    QPushButton* m_previewBgImageBtn;
    QLabel* m_previewLabel;

    // 提醒设置
    QGroupBox* m_reminderGroup;
    QCheckBox* m_desktopNotificationCheck;
    QCheckBox* m_soundNotificationCheck;
    QCheckBox* m_vibrationCheck;
    QCheckBox* m_skipRestCheck;

    // 时间设置
    QGroupBox* m_timeGroup;
    QSpinBox* m_workDurationSpin;
    QSpinBox* m_restDurationSpin;

    // 按钮
    QPushButton* m_applyButton;
    QPushButton* m_resetButton;
    QPushButton* m_cancelButton;
    QPushButton* m_okButton;

    // 当前设置
    QString m_currentWorkSound;
    QString m_currentRestSound;
    QString m_currentBgSound;
    QString m_currentBgImage;

signals:
    void settingsApplied();
};

#endif // TOMATOCONFIGDIALOG_H